package com.xscha.tableforge.jooq.tables;

import org.jooq.Record;
import org.jooq.*;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import java.time.LocalDateTime;

/**
 * 节点元数据表
 * 用于存储应用中的节点信息，包括菜单、页面等
 */
public class NodeMetaTable extends TableImpl<Record> {

    private static final long serialVersionUID = -1L;

    public static final NodeMetaTable NODE_META = new NodeMetaTable();

    /** 主键 */
    public final TableField<Record, Long> ID = createField(DSL.name("id"), SQLDataType.BIGINT.nullable(false), this);
    /** 应用ID */
    public final TableField<Record, String> APP_ID = createField(DSL.name("app_id"), SQLDataType.VARCHAR(50), this);
    /** 父节点ID */
    public final TableField<Record, String> PARENT_ID = createField(DSL.name("parent_id"), SQLDataType.VARCHAR(50), this);
    /** 节点排序 */
    public final TableField<Record, Double> DISPLAY_ORDER = createField(DSL.name("display_order"), SQLDataType.DOUBLE, this);
    /** 节点ID */
    public final TableField<Record, String> NODE_ID = createField(DSL.name("node_id"), SQLDataType.VARCHAR(50), this);
    /** 节点名称 */
    public final TableField<Record, String> NODE_NAME = createField(DSL.name("node_name"), SQLDataType.VARCHAR(255), this);
    /** 图标 */
    public final TableField<Record, String> ICON = createField(DSL.name("icon"), SQLDataType.VARCHAR(255), this);
    /** 节点类型 (0:Root node,1:Folder,2:Datasheet,3:Form,4:Dashboard,5:iFrame) */
    public final TableField<Record, String> NODE_TYPE = createField(DSL.name("node_type"), SQLDataType.VARCHAR(255), this);
    /** 是否显示 */
    public final TableField<Record, Boolean> IS_VISBLE = createField(DSL.name("is_visble"), SQLDataType.BOOLEAN, this);
    /** 扩展信息 */
    public final TableField<Record, String> EXTRA = createField(DSL.name("extra"), SQLDataType.VARCHAR, this);
    /** 删除时间 */
    public final TableField<Record, LocalDateTime> DELETED_TIME = createField(DSL.name("deleted_time"), SQLDataType.LOCALDATETIME(3), this);
    /** 创建时间 */
    public final TableField<Record, LocalDateTime> CREATED_TIME = createField(DSL.name("created_time"), SQLDataType.LOCALDATETIME(3).nullable(false).defaultValue(DSL.field("CURRENT_TIMESTAMP", SQLDataType.LOCALDATETIME)), this);
    /** 创建人 */
    public final TableField<Record, String> CREATED_BY = createField(DSL.name("created_by"), SQLDataType.VARCHAR.nullable(false), this);
    /** 更新人 */
    public final TableField<Record, String> LAST_MODIFIED_BY = createField(DSL.name("last_modified_by"), SQLDataType.VARCHAR, this);
    /** 更新时间 */
    public final TableField<Record, LocalDateTime> LAST_MODIFIED_TIME = createField(DSL.name("last_modified_time"), SQLDataType.LOCALDATETIME(3), this);
    /** 节点地址 */
    public final TableField<Record, String> PATH = createField(DSL.name("path"), SQLDataType.VARCHAR(512), this);

    private NodeMetaTable() {
        super(DSL.name("node_meta"));
    }

    @Override
    public Schema getSchema() {
        return DSL.schema(DSL.name("public"));
    }

    @Override
    public UniqueKey<Record> getPrimaryKey() {
        return Keys.NODE_META_PKEY;
    }

    @Override
    public NodeMetaTable as(String alias) {
        return new NodeMetaTable().as(alias);
    }

    @Override
    public NodeMetaTable as(Name alias) {
        return new NodeMetaTable().as(alias);
    }
} 